#ifndef AGENT01_H
#define AGENT01_H
#include <cstdlib>
#include <ctime>
#include <cmath>
//#include <QtCore>
//#include <sys/time.h>
struct tTempBids {
    double bid;
    int index;
};

class agent01{
public:
    agent01(int numberOfKeywords_,double monthBudget_);
    ~agent01();
    void receiveInfo(int month, int day, int* imps_, int* clicks_, double* cost_, double* pos_);
    double* getBidsForAllKeywords();
    double* getMaxBudgetForAllKeywords();

private:

    void initializeMonth(int month);
    void firstWeekStrategy();
    void strategy4a();
    void strategy4c();
    void strategy4b();
    void totalClickAmountLearn();
    void initialAdjustBudget();
    void finalAdjustBudget();

    //helper functions
    double power(double a, int b);
    double getRandBetween0and1(){return ((double)rand())/RAND_MAX;}
    double getClickAmount(double position,int total);

    int numberOfKeywords;
    double monthBudget = 1000;
    double PClick = 0.2;
    double budgetForDay;
    int weekNumber;
    double budgetRemaining;
    int currentMonth = 0;
    int currentWeekDay = 0;
    int currentMonthDay = 1;
    int *clicksPerKeyword;
    int *impressionsPerKeyword;
    double *costPerKeyword;
    /**
     * @brief positionPerKeyword position that the keyword received last day
     * WARNING: 0-based position
     */
    double *positionPerKeyword;
    //which bids are already set for the next day
    bool *bidsSet;
    /**
     * @brief totalClicksPerKeyword estimation of total distributable clicks per day per keyword
     */
    int *totalClicksPerKeyword[7];
    /**
     * @brief nextBids bids for next day per keyword
     */
    double *nextBids;
    /**
     * @brief nextBudget budget for next day per keyword
     */
    double *nextBudget;


    //temporary variables
    struct tTempBids *tempBids;
};
#endif // AGENT01_H
